/* cImgBuf.h
 * Holds raw RGB pixel data, for fast off-screen rendering.
 */
#ifndef __newmoon_cimgbuf_h
#define __newmoon_cimgbuf_h

class ImgBuf;
#include <list>
#include <string>
#include <gtk/gtk.h>
#include <string.h> //memcpy
#include "debugout.h"
#include "compat.h"
#include "mathx.h"
#include "uint.h"

class ImgBuf {
	public:
		typedef struct {
			u8 Red, Green, Blue, Alpha;
			//NOTE: Alpha is IGNORED when blitting to a GdkDrawable. However I
			//will probably implement it in a function to alpha-blend onto
			//another ImgBuf at some point, if I find it necessary.
		} Pixel;
		
		ImgBuf();
		ImgBuf(u32 Width, u32 Height);
		~ImgBuf();
		
		u32 GetWidth();
		u32 GetHeight();
		Pixel* GetPixels();
		void SetFGColour(u8 R, u8 G, u8 B);
		void DrawPixel(u32 X, u32 Y);
		void DrawPixel(u32 X, u32 Y, u8 R, u8 G, u8 B);
		void DrawRectangle(u32 X, u32 Y, u32 Width, u32 Height, bool Filled);
		void BlitFrom(ImgBuf *Src, u32 SX, u32 SY, u32 DX, u32 DY, u32 W, u32 H);
		bool Resize(u32 Width, u32 Height);
		void Clear();
		void Clear(u8 R, u8 G, u8 B, u8 A);
	
	protected:
		Pixel *Pixels;
		u32 Width, Height;
		u8 FGRed, FGGreen, FGBlue, FGAlpha;
	
	private:
		void _Create(u32 Width, u32 Height);
};
#endif //__newmoon_cimgbuf_h
